package com.xneure.enging.controller;

import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xneure.enging.RequestContext;
import com.xneure.enging.WebContext;
import com.xneure.enging.event.WebEvent;
import com.xneure.enging.widget.Control;
import com.xneure.enging.widget.WidgetManage;

@Controller
@RequestMapping(value = "/event")
public class EventHandler{
	@SuppressWarnings("rawtypes")
	@ResponseBody
	@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST})
	public Object event(Map mzp,WebEvent we){
		Control ele = WidgetManage.getControl(we.getId());
		if(null != ele){
			ele.event(we.getParam(),we.getType());
		}
		return RequestContext.getEventNotify(WebContext.getSession().getId()).getEventResult();
	}
}
